package com.feihao.zhou.TCP.demo02Again;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerDemo {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(10086);
        while (true) {
            Socket accept = serverSocket.accept();

            //读取：
            BufferedReader br = new BufferedReader(new InputStreamReader(accept.getInputStream()));

            String len;
            while ((len = br.readLine()) != null) {
                System.out.println(len);
            }

            //回写：
            OutputStream os = accept.getOutputStream();
            os.write("收到".getBytes());


            br.close();
            os.close();
            accept.close();
        }
    }

}
